<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    /*
    promise讲解
    https://blog.csdn.net/m0_52409770/article/details/123220829?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1-123220829-blog-125414083.pc_relevant_multi_platform_whitelistv4&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1-123220829-blog-125414083.pc_relevant_multi_platform_whitelistv4&utm_relevant_index=2
    
    */
    const p = new Promise((resolve, reject) => {
      const time = new Date().getTime()
      setTimeout(() => {
        if (time % 2 == 0) {
          console.log('成功了', time);
        } else {
          console.log('失败了', time);
        }
      }, 500)
    })
      .then((res) => {
        console.log(res);
      }, (err) => {
        console.log(err);
      })
      // .catch((err) => {
      //   console.log(err);
      // })
      .finally(() => {
        console.log('成功或者失败都执行');
      })

    /*
      
    
    
    
    
    */
  </script>
</body>

</html>